/*
 * @Author: huang liang miao 1127255342@qq.com
 * @Date: 2024-11-08 13:41:01
 * @LastEditors: luosi 1297957337@qq.com
 * @LastEditTime: 2024-12-05 13:46:07
 * @FilePath: \dcy-webd:\webCode\dcyCode\scientific_research_manager_web\src\api\system\user.ts
 * @Description: 用户管理、部门，专业、职称、组织
 */
import request from '@/utils/request'
import {
  AccountPageQuery,
  PageBeanAccountPageVO,
  accountInfos,
  AccountUpdateReqDTO,
  SchoolListRequest,
  SchoolListVO,
  ResourceDetailVO,
  UpdatePasswordReqOpenDTO,
  PageBeanDepartmentPageVO,
  AccountDetailVO,
} from './type'


// 查询用户分页列表
export function getAccountListPage(data: AccountPageQuery) {
  return request<PageBeanAccountPageVO>({
    url: '/resource/api/account/page',
    method: 'post',
    data
  })
}

// 用户导入-批量创建
export function batchCreateListPage(data: accountInfos) {
  return request({
    url: '/resource/api/account/batchCreate',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 用户创建
export function createAccountReq(data: AccountUpdateReqDTO) {
  return request({
    url: '/resource/api/account/create',
    method: 'post',
    data
  })
}

// 用户删除
export function deleteAccountReq(data: {force?: boolean, id?: string}) {
  return request({
    url: '/resource/api/account/delete',
    method: 'post',
    data
  })
}

// 用户修改
export function updateAccountReq(data: AccountUpdateReqDTO) {
  return request({
    url: '/resource/api/account/update',
    method: 'post',
    data
  })
}

// 用户重置密码
export function resetPasswordReq(data: {id: string}) {
  return request({
    url: '/resource/api/account/resetPassword',
    method: 'post',
    data
  })
}

// 用户开启/禁用帐号
export function updateStatusReq(data: {status: boolean, id: string}) {
  return request({
    url: '/resource/api/account/updateStatus',
    method: 'post',
    data
  })
}

// 学院(部)不分页列表
export function getDepartmentListReq() {
  return request<PageBeanDepartmentPageVO>({
    url: '/resource/api/department/list',
    method: 'post',
  })
}
// 学校部门不分页列表
export function getSchoolListReq(data?: SchoolListRequest) {
  return request<SchoolListVO[]>({
    url: '/resource/api/school/list',
    method: 'post',
    data
  })
}
// 用户详情
export function getAccountDetailReq(id: string) {
  return request<AccountDetailVO>({
    url: `/resource/api/account/detail/${id}`,
    method: 'post',
  })
}

// 获取资源信息
export function getUserDetailReq(data?) {
  return request<ResourceDetailVO>({
    url: '/resource/detail',
    method: 'post',
    data
  })
}

// 旧密码修改新密码
export function updatePasswordReq(query?) {
  return request<UpdatePasswordReqOpenDTO>({
    url: '/resource/updatePassword',
    method: 'post',
    data: query
  })
}



